package com.ushio.userservice.coinfig;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
//import jakarta.servlet.http.HttpServletRequest; // spring boot web 3.x 依赖带的
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest; // spring boot 2.x 用

@Component
public class HeaderOriginParser implements RequestOriginParser {
    // 类文件具有错误的版本 61.0, 应为 55.0 // jdk 17 -> 61 // jdk 11 -> 55， 依次增加
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String origin = httpServletRequest.getHeader("origin");
        if(StringUtils.isEmpty(origin)) {
            return "blank";
        }
        return origin;
    }
}

